using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Basic;
namespace eCloudEdit
{
    public partial class EventSetupForm : Form
    {
        private string _EventType="0";
        private string _PageName="";
        private Dictionary<string, RealVar> RDList = new Dictionary<string, RealVar>();
        public EventSetupForm()
        {
            InitializeComponent();
        }
        public void SetList(Dictionary<string, RealVar> RealList)
        {

            RDList = RealList;
        }
        public string GetSelectPageName
        {
             get
            {
                return _PageName;
            }
            set
            {
                _PageName = value;
                //this.comboBox1.SelectedText = _FirstForm;
                int n = this.comboBox1.Items.Count;
                for (int i = 0; i < n; i++)
                {
                    if (this.comboBox1.Items[i].Equals(_PageName))
                    {
                        this.comboBox1.SelectedItem = this.comboBox1.Items[i];
                        break;
                    }
                }
            }
        }
        public void AddPageNames(string sp)
        {
            comboBox1.Items.Add(sp);
        }
        public string GetEventType()
        {
           
                return _EventType;
         
        }
        public void SetEventType(string se)
        {
            _EventType = se;
            if (_EventType == "0")
            {
                radioButton1.Checked = true;
                radioButton2.Checked = false;
                radioButton3.Checked = false;
                radioButton4.Checked = false;
                radioButton5.Checked = false;
            }
            else if (_EventType == "1")
            {
                radioButton1.Checked = false;
                radioButton2.Checked = true;
                radioButton3.Checked = false;
                radioButton4.Checked = false;
                radioButton5.Checked = false;
            }
            else if (_EventType == "2")
            {
                radioButton1.Checked = false;
                radioButton2.Checked = false;
                radioButton3.Checked = true;
                radioButton4.Checked = false;
                radioButton5.Checked = false;
            }
            else if (_EventType == "3")
            {
                radioButton1.Checked = false;
                radioButton2.Checked = false;
                radioButton3.Checked = false;
                radioButton4.Checked = true;
                radioButton5.Checked = false;
            }
            else if (_EventType == "4")
            {
                radioButton1.Checked = false;
                radioButton2.Checked = false;
                radioButton3.Checked = false;
                radioButton4.Checked = false;
                radioButton5.Checked = true;
            }

        }
        public string SetName
        {
            get
            {
                return this.textBox2.Text;
            }
            set
            {
                this.textBox2.Text = value;
            }
        }
        public string SetValue
        {
            get
            {
                return this.textBox1.Text;
            }
            set
            {
                this.textBox1.Text = value;
            }
        }
        public string SwitchName
        {
            get
            {
                return this.textBox3.Text;
            }
            set
            {
                this.textBox3.Text = value;
            }
        }
        public string SwitchValue
        {
            get
            {
                return this.comboBox4.GetItemText(this.comboBox4.SelectedItem);
            }
            set
            {
                string ss = value;
                //this.comboBox1.SelectedText = _FirstForm;
                int n = this.comboBox4.Items.Count;
                for (int i = 0; i < n; i++)
                {
                    if (this.comboBox4.Items[i].Equals(ss))
                    {
                        this.comboBox4.SelectedItem = this.comboBox4.Items[i];
                        break;
                    }
                }
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.OK;
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
        }

        private void comboBox1_DropDownClosed(object sender, EventArgs e)
        {
            int n = this.comboBox1.SelectedIndex;
            if (n >= 0)
            {
                _PageName = this.comboBox1.GetItemText(this.comboBox1.SelectedItem);
            }
        }

        private void radioButton1_CheckedChanged(object sender, EventArgs e)
        {
           
        }

        private void radioButton2_CheckedChanged(object sender, EventArgs e)
        {
           
        }

        private void radioButton3_CheckedChanged(object sender, EventArgs e)
        {
           
        }

        private void radioButton4_CheckedChanged(object sender, EventArgs e)
        {
            
        }

        private void radioButton2_MouseClick(object sender, MouseEventArgs e)
        {
            _EventType = "1";
        }

        private void radioButton3_MouseClick(object sender, MouseEventArgs e)
        {
            _EventType = "2";
        }

        private void radioButton4_MouseClick(object sender, MouseEventArgs e)
        {
            _EventType = "3";
        }

        private void radioButton5_MouseClick(object sender, MouseEventArgs e)
        {
            _EventType = "4";
        }

        private void radioButton1_MouseClick(object sender, MouseEventArgs e)
        {
            _EventType = "0";
        }

        private void radioButton5_CheckedChanged(object sender, EventArgs e)
        {

        }

        private void button3_Click(object sender, EventArgs e)
        {
                SelectRealVarForm form = new SelectRealVarForm();
                form.varname = SetName;
                form.SetList(RDList);
                if (form.ShowDialog() == DialogResult.OK)
                {
                    SetName = form.varname;
                }
        }

        private void button4_Click(object sender, EventArgs e)
        {
            SelectRealVarForm form = new SelectRealVarForm();
            form.varname = SwitchName;
            form.SetList(RDList);
            if (form.ShowDialog() == DialogResult.OK)
            {
                SwitchName = form.varname;
            }
        }
    }
}